sales = []
sale_amt = 0
while True:
    sale_info = input('请输入商品名称和销售额(用逗号隔开，直接回车结束)：')
    if len(sale_info) == 0:
        break
    goods_name, amount = sale_info.split(',')
    sale_amt = sale_amt + float(amount)
    sales.append([goods_name,amount])
sale_file = open('data/sales.txt', 'w', encoding='utf-8')
sale_file.write('销售明细: \n')
for goods_name, amount in sales:
    sale_file.write(goods_name + ',' + amount + '\n')
sale_file.write('销售额合计: {:.2f} 元\n'.format(sale_amt))
sale_file.close()